#include<stdio.h>
#include<ctype.h>
#include<limits.h>

void main(int argc, char** argv)
{
    if (argv[1] == NULL)
    {
        return;
    }
    char* str = argv[1];
    int negative = 0;
    int i = -1;
    int num = 0;
    
    while(str[++i] != '\0' && isspace(str[i]));

    if(str[i] == '+') 
    {
        negative = 0;
        ++i;
    }
    else if (str[i] == '-') 
    {
        negative = 1;
        ++i;
    }

    int digit = 0;
    while(isdigit(str[i]))
    {
        digit = str[i] - '0';
        if (!negative && (num > INT_MAX/10 || (num == INT_MAX/10 && digit > INT_MAX%10)))
        {
            printf("positive overflow\n");
            return;
        }
        else if(negative && (num > (unsigned)INT_MIN/10 || (num == (unsigned)INT_MIN/10 && digit > INT_MIN%10)))
        {
            printf("negative overflow\n");
            return;
        }
        num = num*10 + digit; 
        ++i;
    }

    if(str[i] != '\0')
    {
        printf("invalid input\n");
        return;
    }

    num = (negative ? -1 : 1) * num;
    printf("translate %s to %d\n", argv[1], num);
}
